<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>四川新华扬科技有限公司－企业微信授权</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="../../AceAdmin/assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../../AceAdmin/assets/css/font-awesome.min.css" />
<link rel="stylesheet" href="../../AceAdmin/assets/css/ui.jqgrid.css" />
<link rel="stylesheet" href="../../AceAdmin/assets/css/chosen.css" />
<link rel="stylesheet" href="../../AceAdmin/assets/css/ace.min.css" />
<script src="../../AceAdmin/assets/js/ace-extra.min.js"></script>
<script src="../../js/configuration.js"></script>

<script src="../../js/common.js" type="application/javascript"></script>
<style type="text/css">
      .companytop{
        width: 100%;
        height: 80px;
        border-bottom: 1px solid #ccc;
      }
      .companytopz{
        /*display: flex;*/
        width: 100%;
        height: 100%;
        margin: auto;
        text-align: center;
        line-height: 80px;
        font-size: 18px;
      }
      .companytopz text{
        padding: 0 5px;
      }
      .companytop1{
        color: #1AAD19;
      }
      .color{
        color: #111111;
      }
      .companyBottom{
        width: 100%;
        display: inline-block;
      }
      .companyBottomCom{
        width: 60%;
        margin:auto;
        display: flex;
        margin-top: 50px;
      }
      .companyBottomCom img{
        width: 80px;
        height: 80px;
      }
      .companyBottomCom text{
        width: calc(100% - 80px);
        /*line-height: 40px;*/
        display: block;
        font-size: 17px;
      }
      span{
        color: red;
      }
      .companyBottomComB{
        width: 45%;
        margin: auto;
        padding-top: 50px;
      }
      .companyBottomComB .p1{
        font-size: 14px;
      }
      .companyBottomComB .p2{
        font-size: 12px;
      }
      .buttonDiv{
        width: 100%;
        margin-top: 80px;
      }
      .button{
        width: 150px;
        line-height: 40px;
        background: #1AAD19;
        color: #fff;
        text-align: center;
        border-radius: 5px;
        margin: auto;
        cursor:pointer;
      }
      .companyBottom2{
        width: 100%;
        display: none;
      }
      .communication{
        line-height: 80px;
      }
      .last1{
        width: 150px;
        line-height: 40px;
        color: #808080;
        text-align: center;
        margin: auto;
      }
      .companyBottom3{
        width: 100%;
        display: none;
      }
      .buttonDiv3{
        margin-top: 120px;
        width: 100%;
      }


    .accredit{
        text-align: center;
        font-size: 18px;
        border-bottom:1px solid #ccc;
        line-height: 30px;
    }
    .yes{
        background: #1AAD19;
        color: #fff;
        border-radius: 5px;
    }
    .no{
        background: #fff;
        border-radius: 5px;
        
    }

</style>
</head>
<body>
<div class="company">
<div class="companytop">
    <div class="companytopz">
        <text class="companytop1">1.注册企业微信</text>
        <text class="companytop2 color">--------</text>
        <text class="companytop3 color">2.企业微信通讯录授权</text>
        <text class="companytop4 color">--------</text>
        <text class="companytop5 color">3.企业微信应用授权</text>
    </div>
</div>
<div class="companyBottom">
    <div class="companyBottomCom"><img src="../../imgs/index/company.png"><text><div style="height: 20px;"></div>AI雷达需要企业微信的微信插件提供支持，因此你需要为你的企业申请<span>注册一个企业微信账号</span></text></div>
    <div class="companyBottomComB">
        <p class="p1">注册须知(可查阅：<a href="https://work.weixin.qq.com/wework_admin/register_wx?from=myhome">企业微信注册指引</a>)</p>
        <p class="p2">1.注册时“人员规模”请以实际情况为准，填写数值应大于名片购买数量</p>
        <p class="p2">2.确保小程序和企业微信两者的注册主体保持一致</p>
    </div>
    <div class="buttonDiv">
        <a href="https://work.weixin.qq.com/wework_admin/register_wx?from=myhome" target="_blank"><div class="button register">立即注册</div></a>
        <div style="height: 20px"></div>
        <div class="button lext1">已完成注册，下一步</div>
    </div>
    
</div>
<div class="companyBottom2">
    <div class="companyBottomCom"><img src="../../imgs/index/company.png"><text class='communication'>企业微信通讯录授权</text></div>
    <div class="companyBottomComB">
        <p class="p1">注册须知(可查阅：<a href="https://work.weixin.qq.com/wework_admin/register_wx?from=myhome">企业微信授权指引</a>)</p>
        <p class="p2">1.确保使用新华杨开户营业执照主体信息注册的企业微信进行授权</p>
        <p class="p2">2.授权完成后，<span>等待3秒过程中不可提前关闭页面</span>，否则将导致授权失败</p>
        <p class="p2">3.确保该企业微信，<span>未授权给其他第三方应用</span></p>
        <p class="p2">4.<span>完成授权后，不可更换企业微信</span></p>

    </div>
    <div class="buttonDiv">
        <div class="button lext2">立即授权</div>
        <div class="last1">返回上一步</div>
    </div>
    
</div>
<div class="companyBottom3">
    <div class="companyBottomCom"><img src="../../imgs/index/company.png"><text><div style="height: 20px;"></div>如果你的企业已有企业微信账号，AI名片系统需要企业授权企业微信的通讯录读写权限；否则将无法启用AI雷达、AI名片等产品服务</text></div>
    <div class="companyBottomComB">
        <p class="p1">请确保授权的小程序和企业微信两者的注册主体保持一致</p>
        <p class="p2">更多通讯录授权注意，请查看<a>企业微信通讯录授权指引</a></p>
      
    </div>
    <div class="buttonDiv3 ">
        <div class="button lext3">AI雷达授权</div>>
        <div class="button lext4">BOSS雷达授权</div>
    </div>
    
</div>

</div>
</body>
<script type="text/javascript">
        window.jQuery || document.write("<script src='../../AceAdmin/assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
    </script>
    <script type="text/javascript">
        if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
    </script>
<script src="../../AceAdmin/assets/js/jquery.dataTables.min.js"></script>
<script src="../../AceAdmin/assets/js/jquery.dataTables.bootstrap.js"></script>
<script src="../../AceAdmin/assets/js/bootstrap.min.js"></script>
<script src="../../AceAdmin/assets/js/typeahead-bs2.min.js"></script>
<script src="../../AceAdmin/assets/js/chosen.jquery.min.js"></script>
<script src="../../AceAdmin/assets/js/ace-elements.min.js"></script>
<script src="../../AceAdmin/assets/js/ace.min.js"></script>
<script src="../../AceAdmin/assets/js/bootbox.min.js"></script>
<script type="text/javascript">
    console.log(window.base.getLocalStorage('token'))
    console.log(JSON.stringify(window.base.getLocalStorage('token')))
    $.ajax({
        url:"https://minitest.17jxyx.com/api/v1/thirdapp/auth_info",
        type:"GET",
        beforeSend: function (request) {
            request.setRequestHeader('token', window.base.getLocalStorage('token'));
        },
        success:function(res){
            console.log(res)
        // $.each(res, function(index, el) {
        // if(el == 0){
            console.log(res.contact)
            console.log(res.ai)
            console.log(res.boss)
            if(res.contact == 1&&res.ai == 1&&res.boss == 1){
                alert("您已完成所有授权，将自动为您返回后台管理页面")
                window.location.href = "https://business.17jxyx.com/pages/index.html"
            }
           
            if(res.contact == 0){
                $(".lext1").click(function(){
                    $.ajax({
                        url:"https://minitest.17jxyx.com/api/v1/contact/get_auth_url",
                        type:"GET",
                        beforeSend: function (request) {
                            request.setRequestHeader('token', window.base.getLocalStorage('token'));
                        },
                        success:function(res){
                            console.log(res,"res.contact")
                            $(".companytop2").css("color","#1AAD19")
                            $(".companytop3").css("color","#1AAD19")
                            $(".companyBottom").css("display","none")
                            $(".companyBottom2").css("display","block")
                            $(".lext2").click(function(){
                                bootbox.dialog({
                                    message: "<div class='row'><div class='accredit'>提示</div><div class='accreditBott'>是否授权成功</div></div>",
                                    buttons:{
                                        "还未授权":{
                                            "className": "btn-sm no btn-success",
                                            "callback":function(){ 
                                            }
                                        },
                                        "我已授权成功":{
                                            "className": "btn-sm yes btn-success",
                                            "display":"none",
                                            "callback":function(){ 
                                                $.ajax({
                                                    url:"https://minitest.17jxyx.com/api/v1/thirdapp/auth_info",
                                                    type:"GET",
                                                    beforeSend: function (request) {
                                                        request.setRequestHeader('token', window.base.getLocalStorage('token'));
                                                    },
                                                    success:function(res){
                                                        // console.log(res)
                                                        if(res.contact == 1){
                                                            $(".companytop4").css("color","#1AAD19")
                                                            $(".companytop5").css("color","#1AAD19")
                                                            $(".companyBottom2").css("display","none")
                                                            $(".companyBottom3").css("display","block")
                                                        }else{
                                                           alert("对不起，请重新授权")
                                                        }
                                                    },
                                                    error:function(res){
                                                        tokenDetection(res)
                                                    }
                                                });
                                            }
                                        }
                                     }
                                })
                                $(".modal-content").css("margin-top","20%")
                                window.open(res)

                            })
                            // console.log(res)
                        },
                        error:function(res){
                            tokenDetection(res)
                        }
                    });
                })
            }else{
                $(".companytop2").css("color","#1AAD19")
                $(".companytop3").css("color","#1AAD19")
                $(".companytop4").css("color","#1AAD19")
                $(".companytop5").css("color","#1AAD19")
                $(".companyBottom").css("display","none")
                // $(".companyBottom2").css("display","block")
                $(".companyBottom2").css("display","none")
                $(".companyBottom3").css("display","block")
                if(res.ai == 1){
                    $(".lext3").click(function(){
                        alert("您已经授权成功")
                    })
                }else{
                    $(".lext3").click(function(){
                        // console.log(11111)
                        $.ajax({
                            url:"https://minitest.17jxyx.com/api/v1/ai/get_auth_url",
                            type:"GET",
                            beforeSend: function (request) {
                                request.setRequestHeader('token', window.base.getLocalStorage('token'));
                            },
                            success:function(res){
                                // window.open(res)
                                console.log(res,"res.ai")
                                window.location.href = res
                                // console.log(res)
                            },
                            error:function(res){
                                tokenDetection(res)
                            }
                        });
                    })
                }
                if(res.boss == 1){
                    $(".lext4").click(function(){
                        alert("您已经授权成功")
                    })
                }else{
                    $(".lext4").click(function(){
                        // console.log(888888888)
                         $.ajax({
                            url:"https://minitest.17jxyx.com/api/v1/boss/get_auth_url",
                            type:"GET",
                            beforeSend: function (request) {
                                request.setRequestHeader('token', window.base.getLocalStorage('token'));
                            },
                            success:function(res){
                                // window.open(res)
                                console.log(res,"res.ai")
                                window.location.href = res
                                // console.log(res)
                            },
                            error:function(res){
                                tokenDetection(res)
                            }
                        });
                    })
                    
                }
            }
            console.log(res)
        },
        error:function(res){
            tokenDetection(res)
        }
    });

    // $(".lext1").click(function(){
    //     $.ajax({
    //         url:"https://minitest.17jxyx.com/api/v1/contact/get_auth_url",
    //         type:"GET",
    //         // dataType:"json",
    //         // data:{
    //         //     token:window.base.getLocalStorage('token')
    //         // },
    //         beforeSend: function (request) {
    //             request.setRequestHeader('token', window.base.getLocalStorage('token'));
    //         },
    //         success:function(res){
    //             $(".companytop2").css("color","#1AAD19")
    //             $(".companytop3").css("color","#1AAD19")
    //             $(".companyBottom").css("display","none")
    //             $(".companyBottom2").css("display","block")
    //             $(".lext2").click(function(){
    //             bootbox.dialog({
    //                 message: "<div class='row'><div class='accredit'>提示</div><div class='accreditBott'>是否授权成功</div></div>",
    //                 buttons:{
    //                     "还未授权":{
    //                         "className": "btn-sm no",
    //                         "callback":function(){ 
    //                         }
    //                     },
    //                     "我已授权成功":{
    //                         "className": "btn-sm yes",
    //                         "display":"none",
    //                         "callback":function(){ 
    //                             $(".companytop4").css("color","#1AAD19")
    //                             $(".companytop5").css("color","#1AAD19")
    //                             $(".companyBottom2").css("display","none")
    //                             $(".companyBottom3").css("display","block")
    //                         }
    //                     }
    //                  }
    //             })
    //              $(".modal-content").css("margin-top","20%")
    //                 window.open(res)

    //             })
    //             console.log(res)
    //         },
    //         error:function(res){

    //         }
    //     });
    // })
    $(".last1").click(function(){
        $(".companytop2").css("color","#111111")
        $(".companytop3").css("color","#111111")
        $(".companyBottom2").css("display","none")
        $(".companyBottom").css("display","block")
    })
    // $(".lext2").click(function(){
    //     $(".companytop4").css("color","#1AAD19")
    //     $(".companytop5").css("color","#1AAD19")
    //     $(".companyBottom2").css("display","none")
    //     $(".companyBottom3").css("display","block")
    // })
</script>
</html>